var menuVm=new Vue({
	el: '#repast-list',
  	beforeCompile:function(){
		$("body").LoadingOverlay("show",{
	  		fade : [500, 200]
		});
  	},
  	ready:function(){
  		//处理页码
  		this.page=laypage.handlePage();
  		//填充数据
  		this.handleContent();
  	},
  	data:{
  		page:0,
  		size:10,
  		sort:"created,desc",
  		info:{},
  		initLaypage:false,
  		content:null,
  		menu:null
  	},
  	methods:{
  		showMenu:function(id){
  			this.$http.get("menu/repast",{params:{repastId:id}}).then((response) => {
  				this.menu=response.data;
  				$("#repast-menu-modal").modal("show");
	  		}, (response) => {
	  			$.alt.message("提示",response.body);
	  		});
  		},
  		showDescr:function(message){
  			$.alt.message("备注信息",message);
  		},
  		handleContent:function(){
  			this.$http.post("repast/list",{
  				page:this.page,
  				size:this.size,
  				sort:this.sort
	  		},{emulateJSON : true}).then((response) => {
	  			this.content=response.data['content'];
	  			if(!this.initLaypage){
		  			//分页初始化
		  			laypage({
		  			    cont: 'laypage-ctl',
		  			    skin: 'molv',
		  			    pages: response.data['totalPages'],
		  			    curr: this.page+1,
		  			    //hash: 'page',
		  			    jump: function(o){
		  			    	if(this.initLaypage){
		  			    		$("body").LoadingOverlay("show",{
		  					  		fade : [300, 200]
		  						});
		  			    		this.page=o.curr-1;
			  			    	this.handleContent();
		  			    	}
		  			    }.bind(this)
		  			});
		  			this.initLaypage=true;
	  			}
	  			$("body").LoadingOverlay("hide", true);
	  		}, (response) => {
	  			$.alt.message("提示",response.body);
	  		});
  		},
  		calcTotal:function(array,price,num){
  			var total=0;
  			_.each(array,function(value){
  				total+=value[price]*value[num];
  			});
  			return total.toFixed(2);
  		}
  	}
});